<template>
  <div class="app-container">
    <el-row :gutter="20">
      <!--用户数据-->
      <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch"
               label-width="100px">
        <el-form-item label="单号" prop="orderNumber">
          <el-input v-model="queryParams.orderNumber" placeholder="请输入单号" clearable style="width: 240px"/>
        </el-form-item>
        <el-form-item label="支付流水" prop="serialNumber">
          <el-input v-model="queryParams.serialNumber" placeholder="请输入支付流水" clearable style="width: 240px"/>
        </el-form-item>
        <el-form-item label="流水类型" prop="flowType">
          <el-select v-model="queryParams.flowType" filterable placeholder="请选择流水类型">
            <el-option
              v-for="item in dict.type.erp_flow_type"
              :key="item.value"
              :label="item.label"
              :value="item.value"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="费用类型" prop="expenseType">
          <el-select v-model="queryParams.expenseType" filterable placeholder="请选择费用类型">
            <el-option
              v-for="item in dict.type.erp_expense_type"
              :key="item.value"
              :label="item.label"
              :value="item.value"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="支付方式" prop="payType">
          <el-select v-model="queryParams.payType" filterable placeholder="请选择支付方式">
            <el-option
              v-for="item in dict.type.erp_pay_type"
              :key="item.value"
              :label="item.label"
              :value="item.value"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
          <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
        </el-form-item>
      </el-form>
      <el-row :gutter="10" class="mb10">
        <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
      </el-row>
      <el-table v-loading="loading" :data="flowList" @selection-change="handleSelectionChange" border stripe>
        <el-table-column type="selection" width="50" align="center"/>
        <el-table-column label="单号" align="center" prop="orderNumber"/>
        <el-table-column label="支付流水" align="center" prop="serialNumber"/>
        <el-table-column label="流水类型" align="center" prop="flowType">
          <template slot-scope="scope">
            <dict-tag :options="dict.type.erp_flow_type" :value="scope.row.flowType"></dict-tag>
          </template>
        </el-table-column>
        <el-table-column label="费用类型" align="center" prop="expenseType">
          <template slot-scope="scope">
            <dict-tag :options="dict.type.erp_expense_type" :value="scope.row.expenseType"></dict-tag>
          </template>
        </el-table-column>
        <el-table-column label="实际金额" align="center" prop="money"/>
        <el-table-column label="备注" align="center" prop="remark"/>
        <el-table-column label="发生时间" align="center" prop="addTime"/>
      </el-table>
      <!--  -->
      <pagination v-show="total>0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize"
                  @pagination="getList"/>
    </el-row>
  </div>
</template>

<script>
import {queryStoreWalletLog} from "@/api/distribution";

export default {
  name: "User",
  dicts: ['erp_flow_type', 'erp_pay_type', 'erp_expense_type'],
  data() {
    return {
      tabsValue: "",//选项卡下标
      loading: true, // 遮罩层
      ids: [],  // 选中数组
      single: true, // 非单个禁用
      multiple: true, // 非多个禁用
      showSearch: true,// 显示搜索条件
      total: 0,// 总条数
      flowList: [],// 用户表格数据
      title: "",// 弹出层标题
      open: false,// 是否显示弹出层
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        serialNumber: undefined,//流水号
        flowType: undefined,//流水类型
        expenseType: undefined,//费用类型
        payType: "",//支付方式
        orderNumber: "",//订单号
      },
      branchForm: {},
    };
  },
  created() {
    this.getList();
  },
  methods: {
    // 查询流水明细
    getList() {
      this.loading = true;
      queryStoreWalletLog(this.queryParams).then(response => {
          this.flowList = response.rows;
          this.total = response.total;
          this.loading = false;
        }
      );
    },
    // 表单重置
    reset() {
      this.branchForm = {
        userId: undefined,
        deptId: undefined,
        userName: undefined,
        nickName: undefined,
        password: undefined,
        phonenumber: undefined,
        email: undefined,
        sex: undefined,
        status: "0",
        remark: undefined,
        postIds: [],
        roleIds: []
      };
      this.resetForm("branchForm");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.userId);
      this.single = selection.length != 1;
      this.multiple = !selection.length;
    },
  }
};
</script>
<style lang="scss">

</style>
